import View from "./ExampleGridServerPageEdit.view";
import GridService from "@server/grid/GridService";

interface INP {

}

@YvanUI.BizModule()
export default class Module extends View<Module, INP> {

    gridService = YvanUI.createBroker(GridService);

    onLoad(): void {
        super.onLoad();
    }

    click1() {
        this.refs.theGrid.reload();
        // this.gridService.selectById({user_id:100000}).then(res => {
        //     console.log(res);
        // });
    }

    validateClick() {
        this.refs.theGrid.validate().then(res => {

        }).catch(e => {

        })
    }

    gridRowDetail(sender: YvanUI.CtlGrid, args: YvanUI.CtlGridRowButtonClickArgs) {
        YvanUI.msg(`查看行详情 ${args.data.user_id}`);
    }

    gridDelete(sender: YvanUI.CtlGrid, args: YvanUI.CtlGridRowButtonClickArgs) {
        YvanUI.confirm(`真的要删除 "${args.data.staff_name}" ?`).then(() => {
            YvanUI.msg(`行删除 ${args.data.user_id}`);
        });
    }

    nameValidate(sender: any, value: any) {
        if (!value || value.length < 5) {
            return "字典项长度最少为5"
        }
    }

    nameChange(sender: any, value: any, data: any) {
        data.login_count = String(Number(data.login_count) + 1)
    }

    onRowDelete(sender: any, value: any) {
        debugger
    }
}